#ifndef __SUPER_BLOCK_H__
#define	__SUPER_BLOCK_H__

#include "block.h"
#include "types.h"
#include <time.h>


#define SUPERBLOCK_OFFSET 512
#define SUPERBLOCK_SIZE 512
#define SUPERBLOCK_FREE_BLOCKLIST_SIZE 50
#define SUPERBLOCK_FREE_INODELIST_SIZE 100

struct super_block_t
{
    unsigned char inodeSize[USHORT];  //int          2
    unsigned char volumeSize[UINT]; //int          4
    unsigned char freeListEntries[USHORT]; //int     2
    unsigned char freeBlockList[SUPERBLOCK_FREE_BLOCKLIST_SIZE][UINT]; //int   4 * 50
    unsigned char inodeEntries[USHORT]; // int       2
    unsigned char freeInodeList[SUPERBLOCK_FREE_INODELIST_SIZE][USHORT]; //int  2 * 100

    bool freeBlockListManipulationLock; //      1
    bool inodeListManipulationLock; //          1
    bool modifiedFlag;//                        1
    bool readOnlyFlag; //                       1

    unsigned char lastUpdate[UINT]; //int          4
    unsigned char freeBlocks[UINT]; //int          4
    unsigned char freeInodes[USHORT]; //int          2
    unsigned char interLeaveFactor[USHORT]; //int    2
    unsigned char cylinderSize[USHORT]; //int        2
    unsigned char fileSystemName[6]; //char *   6
    unsigned char systemPackName[6]; //char *   6
};




class SuperBlock : public Block
{
	private:
		super_block_t * superBlock;

	public:
		SuperBlock(FILE*);
		virtual ~SuperBlock();

		ulong getInodeSize();
		ulong getVolumeSize();
		ulong getFreeListEntries();
		ulong * getFreeBlockList();
		ulong getInodeEntries();
		ulong * getFreeInodeList();
		bool getFreeBlockListManipulationLock();
		bool getInodeListManipulationLock();
		bool getModifiedFlag();
		bool getReadOnlyFlag();
		ulong getLastUpdate();
		char * getLastUpdateAsString();
		ulong getFreeBlocks();
		ulong getFreeInodes();
		ulong getInterLeaveFactor();
		ulong getCylinderSize();
		unsigned char * getFileSystemName();
		unsigned char * getSystemPackName();

		virtual void print();
};

#endif
